package PTA_JAVA.JavaB.Javademo21;

import java.util.*;

/**
 * @author win10
 */
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int seed = sc.nextInt();
        Random r = new Random(seed);
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < num; i++) {
            list.add(r.nextInt(10)+1);
        }
        System.out.println(list);

        Iterator<Integer> t1 = list.iterator();
        while(t1.hasNext()){
            int n = t1.next();
            if(n>5){
                t1.remove();
            }
        }
        Iterator<Integer> t = list.iterator();
        while(t.hasNext()){
            int n= t.next();
            System.out.println(n);
        }
    }
}
